package com.hangjiang.gulidear.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * Bug entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "bug", catalog = "sqm")
public class Bug extends BaseEntity {

	// Fields

	private String bugId;
	private Project project;
	private User user;
	private Integer btypeId;
	private String executionUserId;
	private String reappear;
	private Integer severity;
	private Timestamp createTime;
	private Integer status;
	private Set<Task> tasks = new HashSet<Task>(0);

	// Constructors

	/** default constructor */
	public Bug() {
	}

	/** full constructor */
	public Bug(Project project, User user, Integer btypeId,
			String executionUserId, String reappear, Integer severity,
			Timestamp createTime, Integer status) {
		this.project = project;
		this.user = user;
		this.btypeId = btypeId;
		this.executionUserId = executionUserId;
		this.reappear = reappear;
		this.severity = severity;
		this.createTime = createTime;
		this.status = status;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "bugId", unique = true, nullable = false, length = 32)
	public String getBugId() {
		return this.bugId;
	}

	public void setBugId(String bugId) {
		this.bugId = bugId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "projId")
	public Project getProject() {
		return this.project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createUserId")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "bTypeId")
	public Integer getBtypeId() {
		return this.btypeId;
	}

	public void setBtypeId(Integer btypeId) {
		this.btypeId = btypeId;
	}

	@Column(name = "executionUserId", length = 32)
	public String getExecutionUserId() {
		return this.executionUserId;
	}

	public void setExecutionUserId(String executionUserId) {
		this.executionUserId = executionUserId;
	}

	@Column(name = "reappear", length = 200)
	public String getReappear() {
		return this.reappear;
	}

	public void setReappear(String reappear) {
		this.reappear = reappear;
	}

	@Column(name = "severity")
	public Integer getSeverity() {
		return this.severity;
	}

	public void setSeverity(Integer severity) {
		this.severity = severity;
	}

	@Column(name = "createTime", length = 0)
	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "bug")
	public Set<Task> getTasks() {
		return this.tasks;
	}

	public void setTasks(Set<Task> tasks) {
		this.tasks = tasks;
	}

}